#ifndef _U2Rect2D_H__
#define _U2Rect2D_H__


#include "U2PreRequest.h"
#include "U2Renderable.h"
#include "U2Vector2.h"



U2EG_NAMESPACE_BEGIN



class U2Texture;


class _U2Share U2Rect2D : public U2Renderable
{
protected:

    void _initRectangle2D(bool includeTextureCoords, U2HardwareBuffer::Usage vBufUsage);

public:

    U2Rect2D(bool includeTextureCoordinates = false, U2HardwareBuffer::Usage vBufUsage = U2HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);
    /**********************@@@@@@@@@@@@@@@@@@@@@
    U2Rect2D(const U2String& name, bool includeTextureCoordinates = false, U2HardwareBuffer::Usage vBufUsage = U2HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);
    */
    ~U2Rect2D();

    /** Sets the corners of the rectangle, in relative coordinates.
    @param
    left Left position in screen relative coordinates, -1 = left edge, 1.0 = right edge
    @param top Top position in screen relative coordinates, 1 = top edge, -1 = bottom edge
    @param right Right position in screen relative coordinates
    @param bottom Bottom position in screen relative coordinates
	@param updateAABB Tells if you want to recalculate the AABB according to 
	the new corners. If false, the axis aligned bounding box will remain identical.
    */
    void setCorners(u2real left, u2real top, u2real right, u2real bottom, bool updateAABB = true);

	/** Sets the normals of the rectangle
	*/
    /**********************@@@@@@@@@@@@@@@@@@@@@
	void setNormals(const Ogre::Vector3 &topLeft, const Ogre::Vector3 &bottomLeft, const Ogre::Vector3 &topRight, const Ogre::Vector3 &bottomRight);
    */

	/** Sets the UVs of the rectangle
	@remarks
	Doesn't do anything if the rectangle wasn't built with texture coordinates
	*/
	void setUVs( const U2Vector2 &topLeft, const U2Vector2 &bottomLeft,
				 const U2Vector2 &topRight, const U2Vector2 &bottomRight);

	void setDefaultUVs();


protected:
    U2RenderOperation           mRenderOp;
};


U2EG_NAMESPACE_END


#endif
